package com.qhhc.controller;

import com.qhhc.entity.SysUser;
import com.qhhc.service.ISysUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
public class SysUserController {
    @Autowired
    private ISysUserService sysUserService;

    @RequestMapping("/addUser")
    public String insertUser(@RequestBody SysUser user) {
        sysUserService.insertUser(user);
        return "success";
    }

    @RequestMapping("/getAllUsers")
    public List<SysUser> getAllUsers() {
        return sysUserService.selectAll();
    }

    @RequestMapping("/getUser/{id}")
    public SysUser getUserById(@PathVariable("id") Long id) {
        return sysUserService.selectById(id);
    }

    @RequestMapping("/updateUser")
    public String updateUser(@RequestBody SysUser user) {
        sysUserService.updateUser(user);
        return "success";
    }

    @RequestMapping("/deleteUser/{userId}")
    public String deleteUser(@PathVariable("userId") Long userId) {
        sysUserService.deleteUser(userId);
        return "success";
    }
} 